package org.peterf.foxish.scene;

import org.peterf.foxish.camera.Camera;
import org.peterf.foxish.engine.Engine;
import org.peterf.foxish.engine.input.FingerEvent;
import org.peterf.foxish.engine.input.OnTouchListener;

import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;

/**
 * 
 * @author peter
 * 
 */
public abstract class Scene implements OnTouchListener, OnKeyListener {

    public static enum SceneState {
        CREATED, INIT, INVALID, VISIBLE
    }

    protected Engine engine;

    protected OnTouchListener onTouchListener = null;

    protected SceneState state = SceneState.INIT;

    public Scene(Engine engine) {
        this.engine = engine;
    }

    public SceneState getState() {
        return state;
    }

    public abstract void onCreate();

    public abstract void onDestroy();

    public abstract void onDraw(Camera camera, float elapsed);

    public abstract void onRecreate();

    public abstract void onRestored();

    public abstract void onStored();

    public boolean onTouch(FingerEvent event) {
        if (onTouchListener != null) {
            return onTouchListener.onTouch(event);
        } else {
            return false;
        }
    }
    
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        return false;
    }

    public void setOnTouchListener(OnTouchListener l) {
        onTouchListener = l;
    }

    public void setState(SceneState state) {
        this.state = state;
    }

}
